<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = ['top250', 'comingSoon', 'inTheaters'];
        function getData(url) {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve(url)
                }, 1000)
            })
        }

        (async () => {
            // 异步循环 forEach
            // arr.forEach(async item => {
            //     var res = await getData(item);
            //     console.log(res);
            // })

            //同步循环 for of   (支持将异步循环语句变成同步)
            for (let val of arr) {
                let res = await getData(val);
                console.log(res);
            }
        })();
    </script>
</body>

</html>